import '@/plugins/axios'
import '@/plugins/element.js'

export default matchControllers;

function matchControllers(seat) {
  console.log("matchControllers");
  return new Promise((resolve, reject) => {
    this.axios
      .get("./api/get_controllers_by_seat.php?", {
        params: { seat },
        timeout: 5000,
      })
      .then((response) => {
        console.log("matchControllers", response.data);
        if (response.data.count > 0) {
          resolve([response.data.conA.userId, response.data.conB.userId]);
        } else {
          this.$message.warning(
            "未能通过您查询到已打卡人员"
          );
          // reject("未能通过您查询到已打卡人员");
          resolve('');
        }
      })
      .catch((error) => {
        console.error("matchControllers", error);
        this.$message.error(
          "尝试查询席位人员时发生网络错误"
        );
        reject(error);
      });
  });
}